const commonUtil = require('../../util/common');

module.exports = (componentName = '') => {
  // 驼峰组件名
  const H_T_C_N = commonUtil.upperFirst(componentName);

  return `
import type { AppRouteModule } from '/@/router/types';

import { LAYOUT } from '/@/router/constant';

const _prefix_name = '${H_T_C_N}';
const _prefix = '${componentName}';

export const ${H_T_C_N}Names = {
  INDEX: \`\$\{_prefix_name\}Index\`,
};

const routesModules: AppRouteModule = {
  path: \`/\$\{_prefix\}\`,
  name: _prefix_name,
  component: LAYOUT,
  redirect: \`/\$\{_prefix\}/list\`,
  meta: {
    orderNo: 2000,
    icon: 'octicon:project-roadmap-24',
    title: '$1管理',
  },
  children: [
    {
      path: 'index',
      name: ${H_T_C_N}Names.INDEX,
      meta: {
        title: '$1列表',
      },
      component: () => import('/@/views/${componentName}/index.vue'),
    },
  ],
};

export default routesModules;
`;
};
